﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Tests.DateTimeHelper
{
    [TestClass]
    public class WhenUsing
    {
        [TestMethod]
        public void FromUnixTimeShouldReturn6MinutesAfter1970January01()
        {
            double ticks = 360;
            DateTime expected = new DateTime(1970, 1, 1, 0, 6, 0);

            DateTime actual = Be.Timvw.Framework.DateTimeHelper.FromUnixTime(ticks);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ToUnixTimeShouldReturn360For1970January01And6Minutes()
        {
            DateTime input = new DateTime(1970, 1, 1, 0, 6, 0);
            double expected = 360;

            double actual = Be.Timvw.Framework.DateTimeHelper.ToUnixTime(input);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void FirstDayOfWeekShouldReturn2008July21For2008July22()
        {
            DateTime input = new DateTime(2008, 7, 22);
            DateTime expected = new DateTime(2008, 7, 21);

            DateTime actual = Be.Timvw.Framework.DateTimeHelper.FirstDayOfWeek(input);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void FirstDayOfWeekSundayShouldReturn2008July21For2008July27()
        {
            DateTime input = new DateTime(2008, 7, 27);
            DateTime expected = new DateTime(2008, 7, 21);

            DateTime actual = Be.Timvw.Framework.DateTimeHelper.FirstDayOfWeek(input);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void LayDayOfWeekShouldReturn2008July27For2008July22()
        {
            DateTime input = new DateTime(2008, 7, 22);
            DateTime expected = new DateTime(2008, 7, 27);

            DateTime actual = Be.Timvw.Framework.DateTimeHelper.LastDayOfWeek(input);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void LayDayOfWeekSundayShouldReturn2008July27For2008July27()
        {
            DateTime input = new DateTime(2008, 7, 27);
            DateTime expected = new DateTime(2008, 7, 27);

            DateTime actual = Be.Timvw.Framework.DateTimeHelper.LastDayOfWeek(input);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void FirstDayOfMonthShouldReturn2008July01For2008July22()
        {
            DateTime input = new DateTime(2008, 7, 22);
            DateTime expected = new DateTime(2008, 7, 1);

            DateTime actual = Be.Timvw.Framework.DateTimeHelper.FirstDayOfMonth(input);

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void LastDayOfMonthShouldReturn20080July31For2008July22()
        {
            DateTime input = new DateTime(2008, 7, 22);
            DateTime expected = new DateTime(2008, 7, 31);

            DateTime actual = Be.Timvw.Framework.DateTimeHelper.LastDayOfMonth(input);

            Assert.AreEqual(expected, actual);
        }
    }
}